import 'package:boss/ui/page/packageGroup/page/packageGroupDetail/provider/package_group_detail_provider.dart';
import 'package:boss/ui/widget/form/base_text_form_field.dart';
import 'package:boss/ui/widget/title_number_field.dart';
import 'package:boss/ui/widget/form/title_switch.dart';
import 'package:flutter/material.dart';
import 'package:provider/provider.dart';

class PackageGroupDetailHeader extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return Consumer<PackageGroupDetailProvider>(
      builder: (context, provider, _) {
        return Column(
          crossAxisAlignment: CrossAxisAlignment.start,
          children: <Widget>[
            BaseTextFormField(
              prefixText: '分组名称',
              isRequired: true,
              hintText: '请输入套餐分组名称',
              maxLength: 15,
              initialValue: provider.packageGroup.groupName,
              onChanged: (value) {
                provider.setPackageGroupName(value);
              },
            ),
            TitleNumberField(
              title: '菜品必点数量',
              value: provider.packageGroup.count ?? 1,
              onChanged: (value) {
                provider.setPackageGroupCount(value);
              },
            ),
            TitleSwitch(
              title: '菜品能否重复点',
              value: provider.packageGroup.isDuplicated,
              onChanged: (value) {
                provider.togglePackageGroupDuplicated();
              },
            )
          ],
        );
      },
    );
  }
}
